Skip to content

Skip generated files - #29

Merged
nnutter merged 8 commits into
masterfrom
no-generated
Nov 5, 2026
Merged

nnutter merged 8 commits into
masterfrom
no-generated

Conversation

@nnutter

@nnutter nnutter commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

A diagnostic in a generated file is not meaningful because the next run of the generator overwrites the file. Constable now skips files that carry the conventional Go generated-code comment, // Code generated <tool> DO NOT EDIT..

Every analyzer reports on code that a person must fix. Code that a
generator writes has no person to fix it, so the analyzers need one
shared answer to "is this file generated?".

The helper follows the Go convention: the marker comment before the
package clause. An author therefore controls skipping with the comment
alone, and no flag or allow list is necessary.
A generator writes functions with branches that a person cannot
simplify, so the complexity limit reports files that no one may edit.
The methodical fixer already declined to edit generated files. The
new helper gives that rule one name, so the analyzer reads the
convention the same way everywhere.
A generator writes compound conditionals, and the analyzer asks for a
predicate function that no person may add to a generated file.
A generated file can repeat a directive that its body violates, and a
person cannot remove the mutation or the directive there.
A generator writes test helpers that call the testing failure methods,
and a person cannot replace those calls in a generated file.
A generated file holds methods that are not next to their type and not
sorted, and a person cannot move them. A type that a generator writes
also leaves its handwritten methods alone, because those methods can
never move next to the type.
A reader must know that a clean run says nothing about generated files,
and must know how to exclude a file from analysis when a person does
own it.
@nnutter nnutter changed the title Skip generated files in every analyzer Skip generated files Nov 5, 2026
@nnutter
nnutter merged commit d262a43 into master Nov 5, 2026
3 checks passed
@nnutter
nnutter deleted the no-generated branch November 5, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant